package IO;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class IODemo6 {
    public static void main(String[] args) throws IOException {
        //只有实现了Closeable接口,就可以在try里new
        //当执行完try里面的内容时就会自动释放
        try(InputStream inputStream = new FileInputStream("D:/java 2022/java_2022/2022初学/xiaoyubuhuiqiche/7_7网络基础/hello.txt")) {
            int i = 0;
            while (true){
                int t = inputStream.read();//读文件,一次读一个字节,返回值是读取到的字符数量,如果是-1就说明全部读取完了
                if(t == -1){
                    //都到末尾就结束循环
                    break;
                }
                System.out.printf("%X\n",t);
            }
        }
    }
}
